package com.example.mapper;

import com.example.pojo.entity.ShoppingCar;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ShoppingCarMapper {
    @Insert("insert into `shoppingCar`(goods_id,number,price,user_id) values (#{goodsId},#{number},#{price},#{userId})")
    void insert(ShoppingCar shoppingCar);

    @Update("update `shoppingCar` set shoppingCar_num=#{shoppingCarNum},goods_name=#{goodsName},number=#{number},price=#{price},create_time=#{createTime},pay_num=#{payNum},pay_time=#{payTime},shoppingCar_state=#{shoppingCarState},user_id=#{userId} where id=#{id}")
    void updateShoppingCar(ShoppingCar shoppingCar);

    @Delete("delete from `shoppingCar` where id=#{id}")
    void removeById(Integer id);

    @Select("select * from `shoppingCar`")
    List<ShoppingCar> list();

    @Select("select * from `shoppingCar `where id=#{id}")
    ShoppingCar getById(Integer id);


    List<ShoppingCar> selectByPage( Integer goodsId, Integer userId);

    @Select("select * from `shoppingCar` where shoppingCar_num=#{shoppingCarNum}")
    ShoppingCar getByShoppingCarNum(String shoppingCarNum);
}
